package com.mccrea.pattern.adapter.objectadapter;

/**
 * @Classname VoltageAdapter
 * @Description 适配器类
 * @Date 2021/5/8 0008 15:33
 * @Created by Mccrea_Gao
 */
public class VoltageAdapter implements IVoltage5V {

    private Voltage220V voltage220V;

    public VoltageAdapter(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }

    @Override
    public int outPut5V() {
        int dstV = 0;
        if (null != voltage220V) {
            // 获取220V电压
            int srcV = voltage220V.outPut220V();
            // 降压到5V
            dstV = srcV / 44;
        }

        return dstV;
    }
}
